package com.example.logistics_oa.controller;


import com.example.comment_oa.pojos.xinzi.JibenKaoqinhesuan;
import com.example.comment_oa.pojos.xinzi.JibenXinzijisuan;
import com.example.comment_oa.response.AjaxResponse;
import com.example.logistics_oa.service.JibenKaoqinhesuanService;
import com.example.logistics_oa.service.JibenXinzijisuanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/logisticsOa")
@CrossOrigin
public class JiBenXinZiController {

    @Autowired
    JibenXinzijisuanService jibenXinzijisuanService;
    @Autowired
    JibenKaoqinhesuanService jibenKaoqinhesuanService;

    @PostMapping("/jibenxinzi/{jibenId}")
    public AjaxResponse selectall(@PathVariable("jibenId") String jibenId){
        List<JibenXinzijisuan> jibenXinzijisuans = jibenXinzijisuanService.selectByJibenId(jibenId);
        return AjaxResponse.success(jibenXinzijisuans);
    }

    @PostMapping("/kaoqinhesaun/{jibenId}")
    public AjaxResponse selectall2(@PathVariable("jibenId") String jibenId){
        List<JibenKaoqinhesuan> selectall = jibenKaoqinhesuanService.selectall(jibenId);
        return AjaxResponse.success(selectall);
    }

    @PostMapping("/updateIssendOne/{jibenzhujian}")
    public AjaxResponse xiugaiJibenOne(@PathVariable("jibenzhujian") int jibenzhujian){
        int i = jibenXinzijisuanService.updateIssendOne(jibenzhujian);
        return AjaxResponse.success();
    }
    @PostMapping("/updateIssendAll/{jibenId}")
    public AjaxResponse xiugaiJibenAll(@PathVariable("jibenId") String jibenId){
        int i = jibenXinzijisuanService.updateIssendAll(jibenId);
        return AjaxResponse.success();
    }

}
